package org.example.mine.mapper;

import cn.hutool.core.date.DateTime;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.model.domain.mine.ExpressPaymentRecords;
import org.example.model.domain.mine.ExpressRechargeRecord;
import org.example.model.domain.mine.ExpressWithdraw;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface BillMapper {
    @Select("select * from express_withdraw where status=2 and register_ip=#{registerIp} order by over_time desc")
    List<ExpressWithdraw> selectBillList(Long registerIp);

    @Select("select * from express_payment_records where id=#{id}")
    ExpressPaymentRecords getbillbyId(Long id);

    @Select("select * from express_recharge_record where status=3 and register_ip=#{registerIp} order by over_time desc")
    List<ExpressRechargeRecord> selecttopup(Long registerIp);


    @Select("select if(sum(recharge_amount) is NULL,0,sum(recharge_amount)) from express_recharge_record where status=3 and register_ip=#{registerIp} and over_time BETWEEN #{begin} and #{end} ")
    BigDecimal getDailyIncome(DateTime begin, DateTime end, Long registerIp);
}
